<?php

if (!defined('IN_ADMIN')) {
    exit('Access Denied');
}

$mpurl = 'admin.php?ac=inform';
$list = array();

if ($_GET ['op'] == "getLbsByUser") {
    
    $start = intval($_GET ['start']);
    $perpage = intval($_GET ['perpage']) > 0 ? intval($_GET ['perpage']) : 20;
    isset($_GET['uid'])         &&    $info['uid']             =    intval($_GET['uid']);
    !empty($_GET['province'])    &&    $info['province']        =    $_GET['province'];
    !empty($_GET['city'])        &&    $info['city']            =    $_GET['city'];
    !empty($_GET['region'])      &&    $info['region']          =    $_GET['region'];
    isset($_GET['longitude'])   &&    $info['longitude']       =    $_GET['longitude'];
    isset($_GET['latitude'])    &&    $info['latitude']        =    $_GET['latitude'];
    
    $param = array(
            'do' => 'getLbsByUser',
            'format' => 'json',
            'start'  => $start,
            'length' => $perpage,
    );
    if(is_array($info)){
        foreach ($info as $key => $value){
            if($value =='') continue;
            $param[$key] = $value; 
        }
    }
    
    $content = get_api_content($_SC ['apiurl'], $param);
    $content = json_decode($content);
    $list = object_to_array($content->resultData);
    
    require ($_SC['propath']."data/Province.php");
    $list['pros'] = Province::$province;
  
    include_once template("admin/".'LbsUser');
    exit;
}elseif ($_GET ['op'] == "geLbsByDiary"){
    
    isset($_GET['uid'])         &&    $info['uid']             =    intval($_GET['uid']);
    isset($_GET['province'])    &&    $info['province']        =    $_GET['province'];
    isset($_GET['city'])        &&    $info['city']            =    $_GET['city'];
    isset($_GET['region'])      &&    $info['region']          =    $_GET['region'];
    isset($_GET['longitude'])   &&    $info['longitude']       =    $_GET['longitude'];
    isset($_GET['latitude'])    &&    $info['latitude']        =    $_GET['latitude'];
    
    $param = array(
            'do' => 'geLbsByDiary',
            'format' => 'json',
    );
    if(is_array($info)){
        foreach ($info as $key => $value){
            if($value =='') continue;
            $param[$key] = $value;
        }
    }
    $content = get_api_content($_SC ['apiurl'], $param);
    $content = json_decode($content);
    $list = object_to_array($content->resultData);
    include_once template("admin/".'LbsDiary');
    exit;
    
}elseif ($_GET ['op'] == "removeLbsInfo"){
    
    $uid             =    intval($_GET['uid']);
    $param = array(
            'do'     => 'removeLbsInfo',
            'format' => 'json',
            'uid'    => $uid,
    );
    $content = get_api_content($_SC ['apiurl'], $param);
    $content = json_decode($content);
    if ($content->resultData == 1) {
        $msg = "操作成功!";
        cpmessage($msg);
    }
    $msg = "操作失败，请重试一次!";
    if ($content->errorNo) {
        $msg .= "errorNo:" . $content->errorNo;
    }
    cpmessage($msg);
}elseif ($_GET ['op'] == "getCityList"){
    require ($_SC['propath']."data/Province.php");
    $proId = intval($_GET['cityId']);
    $cityList =array();
    $cityList = Province::$city[$proId];
    echo json_encode($cityList);
    exit;
}